import { BasePageDto } from '@/common/base/base.dto';
import { ApiProperty, ApiPropertyOptional, PartialType } from '@nestjs/swagger';
import {
  IsEnum,
  IsInt,
  IsNotEmpty, IsObject,
  IsOptional,
  IsString, IsUUID,
  Max, MaxLength,
  Min,
} from 'class-validator';
import { BooleanNumber, CarouselMobileJumpType, CarouselPositionCode } from "common/utils/data";

export class CarouselAllDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsEnum(CarouselPositionCode)
  positionCode: CarouselPositionCode;
}

export class CarouselAdminIndexDto extends BasePageDto {
  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  title?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;

  @IsOptional()
  @ApiPropertyOptional()
  @IsEnum(CarouselPositionCode)
  positionCode?: CarouselPositionCode;
}

export class CarouselAdminCreateDto {
  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  @MaxLength(500)
  title: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  @MaxLength(500)
  img: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsString()
  @MaxLength(500)
  url: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  @MaxLength(500)
  desc?: string;

  @IsNotEmpty()
  @ApiProperty()
  @IsInt()
  @Max(999)
  @Min(1)
  sort: number;

  @IsNotEmpty()
  @ApiProperty()
  @IsEnum(CarouselMobileJumpType)
  mobileJumpType: CarouselMobileJumpType;

  @IsOptional()
  @ApiPropertyOptional()
  @IsString()
  @MaxLength(50)
  mobileJumpId?: string;

  @IsOptional()
  @ApiPropertyOptional()
  @IsObject()
  mobileJumpExtra?: any;

  @IsNotEmpty()
  @ApiProperty()
  @IsEnum(CarouselPositionCode)
  positionCode: CarouselPositionCode;
}

export class CarouselAdminUpdateDto extends PartialType(CarouselAdminCreateDto){
  @IsOptional()
  @ApiPropertyOptional({
    description: '启用禁用',
  })
  @IsEnum(BooleanNumber)
  status?: BooleanNumber;
}
